﻿// -------------------------------------------------------------------------
//    @FileName         :    NFOnlineRoleService.cpp
//    @Author           :    gaoyi
//    @Date             :    2025-03-29
//    @Email			:    445267987@qq.com
//    @Module           :    NFOnlineRoleService
//
// -------------------------------------------------------------------------

#include "NFSnsOnlineRoleService.h"

#include <NFComm/NFObjCommon/NFRawObject.h>

NFSnsOnlineRole* NFSnsOnlineRoleService::GetOnlineRole(uint64_t roleId)
{
    return NFSnsOnlineRole::GetObjByHashKey(roleId);
}

NFSnsOnlineRole* NFSnsOnlineRoleService::AddOnlineRole(uint64_t roleId)
{
    auto pOnline = GetOnlineRole(roleId);
    if (pOnline)
    {
        return pOnline;
    }

    pOnline = NFSnsOnlineRole::CreateObjByHashKey(roleId);
    CHECK_NULL_RE_NULL(roleId, pOnline, "CreateObjByHashKey failed, space not enough, used count:{} all count:{}", NFSnsOnlineRole::GetStaticUsedCount(), NFSnsOnlineRole::GetStaticItemCount());
    return pOnline;
}

int NFSnsOnlineRoleService::DelOnlineRole(uint64_t roleId)
{
    auto pOnline = GetOnlineRole(roleId);
    CHECK_NULL_WF(roleId, pOnline, "GetOnlineRole failed");
    LOG_INFO(roleId, "DelOnlineRole Success, roleId:{}", roleId);
    NFSnsOnlineRole::DestroyObj(pOnline);
    return 0;
}
